# Generated by Django 4.2.7 on 2024-04-02 08:15

from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Container",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "used",
                    models.BooleanField(
                        default=False,
                        help_text="Занятый контейнер не отображается в пустых",
                        verbose_name="Занят",
                    ),
                ),
                (
                    "nkv",
                    models.PositiveIntegerField(default=0, verbose_name="Номер наряда"),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Id_last",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "number",
                    models.PositiveIntegerField(
                        unique=True,
                        validators=[
                            django.core.validators.MinValueValidator(0),
                            django.core.validators.MaxValueValidator(9999999),
                        ],
                        verbose_name="ID последнего этапа",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Kadr_sdl",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("create_at", models.DateTimeField(default=django.utils.timezone.now)),
                ("update_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Patient",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("create_at", models.DateTimeField(default=django.utils.timezone.now)),
                ("update_at", models.DateTimeField(auto_now=True)),
                ("uid", models.PositiveIntegerField(unique=True)),
                ("fam", models.CharField(max_length=40)),
                ("im", models.CharField(max_length=40)),
                ("ot", models.CharField(blank=True, default="", max_length=40)),
                ("dr", models.DateField()),
                ("adress", models.CharField(blank=True, max_length=100)),
            ],
            options={
                "verbose_name": "Пациенты",
                "verbose_name_plural": "Пациенты",
            },
        ),
        migrations.CreateModel(
            name="Pl_uslp",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("idkv", models.PositiveIntegerField()),
                ("kusl", models.CharField(max_length=50)),
                ("usl", models.PositiveIntegerField()),
                ("nusl", models.CharField(max_length=200)),
                ("kol", models.PositiveIntegerField()),
                ("uet", models.FloatField()),
                ("price", models.DecimalField(decimal_places=2, max_digits=10)),
                ("stu", models.DecimalField(decimal_places=2, max_digits=10)),
                (
                    "tech",
                    models.DecimalField(decimal_places=2, default=0.0, max_digits=10),
                ),
                (
                    "pol",
                    models.DecimalField(decimal_places=2, default=0.0, max_digits=10),
                ),
                (
                    "lit",
                    models.DecimalField(decimal_places=2, default=0.0, max_digits=10),
                ),
                (
                    "cadcam",
                    models.DecimalField(decimal_places=2, default=0.0, max_digits=10),
                ),
                (
                    "gips",
                    models.DecimalField(decimal_places=2, default=0.0, max_digits=10),
                ),
            ],
            options={
                "verbose_name": "Услуги",
                "verbose_name_plural": "Услуги",
            },
        ),
        migrations.CreateModel(
            name="Sdl_set",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("create_at", models.DateTimeField(default=django.utils.timezone.now)),
                ("update_at", models.DateTimeField(auto_now=True)),
                (
                    "doc",
                    models.IntegerField(
                        validators=[
                            django.core.validators.MinValueValidator(0),
                            django.core.validators.MaxValueValidator(9999999),
                        ]
                    ),
                ),
                (
                    "tech",
                    models.IntegerField(
                        default=0,
                        validators=[
                            django.core.validators.MinValueValidator(0),
                            django.core.validators.MaxValueValidator(9999999),
                        ],
                    ),
                ),
                (
                    "lit",
                    models.IntegerField(
                        default=0,
                        validators=[
                            django.core.validators.MinValueValidator(0),
                            django.core.validators.MaxValueValidator(9999999),
                        ],
                    ),
                ),
                (
                    "pol",
                    models.IntegerField(
                        default=0,
                        validators=[
                            django.core.validators.MinValueValidator(0),
                            django.core.validators.MaxValueValidator(9999999),
                        ],
                    ),
                ),
                (
                    "cadcam",
                    models.IntegerField(
                        default=0,
                        validators=[
                            django.core.validators.MinValueValidator(0),
                            django.core.validators.MaxValueValidator(9999999),
                        ],
                    ),
                ),
                (
                    "tech_st",
                    models.IntegerField(
                        default=0,
                        validators=[
                            django.core.validators.MinValueValidator(0),
                            django.core.validators.MaxValueValidator(9999999),
                        ],
                    ),
                ),
            ],
            options={
                "verbose_name": "Установка сотрудников на наряд",
                "verbose_name_plural": "Установка сотрудников на наряд",
            },
        ),
        migrations.CreateModel(
            name="Spr_access",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("create_at", models.DateTimeField(default=django.utils.timezone.now)),
                ("update_at", models.DateTimeField(auto_now=True)),
                (
                    "access",
                    models.CharField(max_length=50, verbose_name="Доступ (латиница)"),
                ),
                (
                    "access_name",
                    models.CharField(
                        max_length=50, verbose_name="Расшифровка (русский)"
                    ),
                ),
            ],
            options={
                "verbose_name": "Права доступа",
                "verbose_name_plural": "Права доступа",
            },
        ),
        migrations.CreateModel(
            name="Spr_lab",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("create_at", models.DateTimeField(default=django.utils.timezone.now)),
                ("update_at", models.DateTimeField(auto_now=True)),
                ("lab", models.PositiveIntegerField()),
                ("name_lab", models.CharField(max_length=100)),
            ],
            options={
                "verbose_name": "Справочник лабораторий",
                "verbose_name_plural": "Справочник лабораторий",
            },
        ),
        migrations.CreateModel(
            name="Spr_lpu",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("create_at", models.DateTimeField(default=django.utils.timezone.now)),
                ("update_at", models.DateTimeField(auto_now=True)),
                ("lpu", models.PositiveIntegerField(unique=True)),
                ("name_lpu", models.CharField(max_length=100)),
                ("adress", models.CharField(blank=True, max_length=100)),
            ],
            options={
                "verbose_name": "Справочник ЛПУ",
                "verbose_name_plural": "Справочник ЛПУ",
            },
        ),
        migrations.CreateModel(
            name="Spr_opl",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("create_at", models.DateTimeField(default=django.utils.timezone.now)),
                ("update_at", models.DateTimeField(auto_now=True)),
                (
                    "opl",
                    models.PositiveIntegerField(
                        unique=True,
                        validators=[
                            django.core.validators.MinValueValidator(0),
                            django.core.validators.MaxValueValidator(99),
                        ],
                    ),
                ),
                ("name_opl", models.CharField(max_length=100)),
            ],
            options={
                "verbose_name": "Справочник оплаты",
                "verbose_name_plural": "Справочник оплаты",
            },
        ),
        migrations.CreateModel(
            name="Spr_sdl",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("create_at", models.DateTimeField(default=django.utils.timezone.now)),
                ("update_at", models.DateTimeField(auto_now=True)),
                ("sdl", models.PositiveIntegerField(unique=True)),
                ("name_sdl", models.CharField(blank=True, max_length=100)),
            ],
            options={
                "verbose_name": "Справочник должностей",
                "verbose_name_plural": "Справочник должностей",
            },
        ),
        migrations.CreateModel(
            name="Zav_pdr",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("mpp", models.PositiveIntegerField()),
                ("years", models.PositiveIntegerField()),
                ("months", models.PositiveIntegerField()),
                ("opl", models.JSONField()),
                ("kol_lab", models.PositiveIntegerField(blank=True, null=True)),
                ("kol_usl", models.PositiveIntegerField(blank=True, null=True)),
                ("kol_all", models.PositiveIntegerField()),
                ("stu_lab", models.DecimalField(decimal_places=2, max_digits=10)),
                ("stu_usl", models.DecimalField(decimal_places=2, max_digits=10)),
                ("stu_all", models.DecimalField(decimal_places=2, max_digits=10)),
                ("nars_lab", models.JSONField()),
                ("nars_usl", models.JSONField()),
                ("nars_lab_approved", models.JSONField()),
                ("nars_usl_approved", models.JSONField()),
                ("nars_lab_cancel", models.JSONField()),
                ("nars_usl_cancel", models.JSONField()),
                ("log", models.TextField()),
            ],
        ),
        migrations.CreateModel(
            name="Zav_report",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("create_at", models.DateTimeField(default=django.utils.timezone.now)),
                ("update_at", models.DateTimeField(auto_now=True)),
                ("mpp", models.PositiveIntegerField()),
                ("year", models.PositiveIntegerField()),
                ("month", models.PositiveIntegerField()),
                ("dn", models.CharField(max_length=50)),
                ("dk", models.CharField(max_length=50)),
                ("opl", models.JSONField()),
                ("kol_lab", models.PositiveIntegerField(blank=True, null=True)),
                ("kol_usl", models.PositiveIntegerField(blank=True, null=True)),
                ("kol_all", models.PositiveIntegerField()),
                ("stu_lab", models.DecimalField(decimal_places=2, max_digits=10)),
                ("stu_usl", models.DecimalField(decimal_places=2, max_digits=10)),
                ("stu_all", models.DecimalField(decimal_places=2, max_digits=10)),
                ("nars_lab", models.JSONField()),
                ("nars_usl", models.JSONField()),
                ("nars_lab_cancel", models.JSONField()),
                ("nars_usl_cancel", models.JSONField()),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="User_sdl",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("create_at", models.DateTimeField(default=django.utils.timezone.now)),
                ("update_at", models.DateTimeField(auto_now=True)),
                (
                    "access",
                    models.ManyToManyField(
                        to="naryad.spr_access", verbose_name="Доступ"
                    ),
                ),
                (
                    "lpu",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="naryad.spr_lpu",
                        verbose_name="ЛПУ",
                    ),
                ),
                (
                    "sdls",
                    models.ManyToManyField(
                        to="naryad.spr_sdl", verbose_name="Должность"
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Пользователь",
                    ),
                ),
            ],
            options={
                "verbose_name": "Сотрудники",
                "verbose_name_plural": "Сотрудники",
            },
        ),
        migrations.CreateModel(
            name="Mpp_podr",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("create_at", models.DateTimeField(default=django.utils.timezone.now)),
                ("update_at", models.DateTimeField(auto_now=True)),
                ("podr", models.JSONField(null=True, verbose_name="Подразделения")),
                (
                    "mpp",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Пользователь",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Mooving",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "date_create",
                    models.DateTimeField(
                        default=django.utils.timezone.now,
                        verbose_name="Дата создания документа",
                    ),
                ),
                ("date_done", models.DateTimeField(blank=True, null=True)),
                (
                    "send_from",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="send_from",
                        to="naryad.spr_lpu",
                        verbose_name="Отправка из",
                    ),
                ),
                (
                    "send_to",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="send_to",
                        to="naryad.spr_lpu",
                        verbose_name="Отправка в",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Kadr_sdl_connect",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("create_at", models.DateTimeField(default=django.utils.timezone.now)),
                ("update_at", models.DateTimeField(auto_now=True)),
                (
                    "kadr_sdl",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="naryad.kadr_sdl",
                    ),
                ),
                (
                    "sdl",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="naryad.spr_sdl"
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.AddField(
            model_name="kadr_sdl",
            name="sdls",
            field=models.ManyToManyField(
                through="naryad.Kadr_sdl_connect", to=settings.AUTH_USER_MODEL
            ),
        ),
        migrations.CreateModel(
            name="It_lab",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "idkv",
                    models.PositiveIntegerField(
                        validators=[
                            django.core.validators.MinValueValidator(0),
                            django.core.validators.MaxValueValidator(9999999),
                        ],
                        verbose_name="IDKV",
                    ),
                ),
                (
                    "nkv",
                    models.PositiveIntegerField(
                        validators=[
                            django.core.validators.MinValueValidator(0),
                            django.core.validators.MaxValueValidator(9999999),
                        ],
                        verbose_name="NKV",
                    ),
                ),
                ("dou", models.DateField(verbose_name="Дата обращения")),
                (
                    "dzr",
                    models.DateField(
                        blank=True, null=True, verbose_name="Дата закрытия наряда"
                    ),
                ),
                (
                    "pdzr",
                    models.DateField(
                        blank=True, null=True, verbose_name="Предварительная ДЗР"
                    ),
                ),
                (
                    "check_zav",
                    models.BooleanField(default=False, verbose_name="Отметка Зав."),
                ),
                (
                    "check_tech",
                    models.BooleanField(default=False, verbose_name="Отметка Tex."),
                ),
                (
                    "status",
                    models.PositiveIntegerField(default=0, verbose_name="Статус"),
                ),
                (
                    "stu",
                    models.DecimalField(
                        decimal_places=2, max_digits=10, verbose_name="Стоимость"
                    ),
                ),
                (
                    "id_etap",
                    models.PositiveIntegerField(default=0, verbose_name="Номер этапа"),
                ),
                (
                    "dn_etap",
                    models.DateField(
                        auto_now=True, null=True, verbose_name="Дата назначения этапа"
                    ),
                ),
                (
                    "dz_etap",
                    models.DateField(
                        blank=True, null=True, verbose_name="Дата завершения этапа"
                    ),
                ),
                (
                    "user_etap",
                    models.CharField(
                        blank=True,
                        default="",
                        max_length=40,
                        verbose_name="Пользователь этапа",
                    ),
                ),
                (
                    "mpp_etap",
                    models.PositiveIntegerField(
                        validators=[
                            django.core.validators.MinValueValidator(0),
                            django.core.validators.MaxValueValidator(9999999),
                        ],
                        verbose_name="МПП этапа",
                    ),
                ),
                (
                    "kom_etap",
                    models.CharField(
                        blank=True,
                        default="",
                        max_length=300,
                        verbose_name="Комментарий этапа",
                    ),
                ),
                ("image_count", models.PositiveIntegerField(default=0)),
                (
                    "container",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="naryad.container",
                        verbose_name="Контейнер",
                    ),
                ),
                (
                    "lpu",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="naryad.spr_lpu",
                        verbose_name="ЛПУ",
                    ),
                ),
                (
                    "naryad_doc",
                    models.ForeignKey(
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="naryad.user_sdl",
                        verbose_name="Доктор наряда",
                    ),
                ),
                (
                    "opl",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="naryad.spr_opl",
                        verbose_name="Тип оплаты",
                    ),
                ),
                (
                    "patient",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="naryad.patient",
                        verbose_name="Пациент",
                    ),
                ),
                (
                    "sdl_etap",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="naryad.spr_sdl",
                        verbose_name="Должность этапа",
                    ),
                ),
                (
                    "sdl_set",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="naryad.sdl_set",
                        verbose_name="Ha6op должностей наряда",
                    ),
                ),
                (
                    "user_etap_link",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="Специалист этапа",
                    ),
                ),
                (
                    "uslugi",
                    models.ManyToManyField(
                        blank=True, to="naryad.pl_uslp", verbose_name="Услуги наряда"
                    ),
                ),
            ],
            options={
                "verbose_name": "Наряды",
                "verbose_name_plural": "Наряды",
            },
        ),
        migrations.CreateModel(
            name="Images",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "naryad",
                    models.PositiveIntegerField(default=0, verbose_name="Номер наряда"),
                ),
                (
                    "img",
                    models.ImageField(
                        blank=True, upload_to="photos/%Y/%m/%d/", verbose_name="Фото"
                    ),
                ),
                (
                    "user_mpp",
                    models.PositiveIntegerField(default=0, verbose_name="Пользователь"),
                ),
                (
                    "etap",
                    models.ForeignKey(
                        default=None,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="images",
                        to="naryad.it_lab",
                        verbose_name="Этап",
                    ),
                ),
            ],
            options={
                "verbose_name": "Изображения",
                "verbose_name_plural": "Изображения",
            },
        ),
        migrations.CreateModel(
            name="Etaps",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("etap", models.PositiveIntegerField(blank=True, null=True)),
                ("dn", models.DateTimeField(auto_now=True)),
                ("dz", models.DateTimeField(blank=True, null=True)),
                (
                    "naryad",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="etaps",
                        to="naryad.it_lab",
                    ),
                ),
                (
                    "sdl",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        to="naryad.spr_sdl",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Этапы выполнения наряда",
                "verbose_name_plural": "Этапы выполнения наряда",
            },
        ),
        migrations.CreateModel(
            name="Comments",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("date", models.DateTimeField(auto_now=True)),
                ("comment", models.TextField()),
                (
                    "naryad",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="comments",
                        to="naryad.it_lab",
                    ),
                ),
                (
                    "sdl",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        to="naryad.spr_sdl",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Этапы выполнения наряда",
                "verbose_name_plural": "Этапы выполнения наряда",
            },
        ),
    ]
